<template>
    <div class="table-box">
        <ProTable ref="proTable" :requestApi="api.getList" :columns="columns">
            <!-- 表格 header 按钮 -->
            <template #tableHeader="scope">
                <el-button type="danger" :icon="Delete" plain :disabled="!scope.isSelected"
                    @click="onBatchRemove(scope.ids)">
                    批量删除参数
                </el-button>
            </template>
            <!-- Expand -->
            <template #expand="scope">
                {{ scope.row }}
            </template>
            <!-- 表格操作 -->
            <template #operation="scope">
                <el-button type="primary" link :icon="Delete" @click="onRemove(scope.row)">删除</el-button>
            </template>
        </ProTable>
    </div>
</template>

<script setup lang="tsx" name="webLog">

import { ref, reactive } from "vue";
import { Delete } from "@element-plus/icons-vue";

import { useHandleData } from "/@/hooks/useHandleData";

import * as api from "/@/api/logger/webLog";
import columnsFunction from './columns';
import ProTable from "/@/components/ProTable/index.vue";

// 获取 ProTable 元素，调用其获取刷新数据方法（还能获取到当前查询参数，方便导出携带参数）
const proTable = ref();

const stackTraceDialog = reactive({
    visible: false,
    stackTrace: ''
})

// 获取表头信息
const columns = columnsFunction();


// 删除
const onRemove = async (params: any) => {
    await useHandleData(api.remove, { id: params.id }, `删除访问日志`);
    proTable.value.refresh();
};

// 批量删除
const onBatchRemove = async (ids: string[]) => {
    await useHandleData(api.remove, { ids }, "删除所选信息");
    proTable.value.refresh();
};

</script>
